package com.example.helloworld.controller;

import com.example.helloworld.mq.service.DelayedMessageProducer;
import com.example.helloworld.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestRabbitController {

    @Autowired
    private DelayedMessageProducer producer;

    @GetMapping("sendMsg")
    private String testDelayedMessage() {
        // 发送3条不同延迟时间的消息
        System.out.println("---------------发送消息开始----------");
        // 5秒后接收
        producer.sendDelayedMessage("延迟5秒的消息", 5000);
        // 10秒后接收
        producer.sendDelayedMessage("延迟10秒的消息", 10000);
        // 3秒后接收
        producer.sendDelayedMessage("延迟3秒的消息", 3000);
        System.out.println("----------发送消息结束----------");
        return "OK";
    }


}
